<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.sql.*" %><!-- 数据库操作需要 -->  
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>用车申请审核表</title>
    <link rel="stylesheet" href="UC_style.css">
    <style>
        .main {
            width: 100%;
            height: 800px;
            background: RGB(239,239,239);
            float: left;
        }

        #header2 {
            height: 40px;
            background: white;
        }

        table,
        th,
        td {
            background-color: white;
            border: 1px solid black;
            border-collapse: collapse;
           
        }

        td {
            width: 200px;
            height: 25px;
            padding: 5px;
           
        }

        th {
            font-size: 16px;
        }

        .had {
            text-align: center;
            height: 600px;
            width: 80%;
            margin: 0px auto;
        }

        .input1 {
            border: none;
            height: 90%;
            width: 100%;
            font-size:16px;
            outline:none;
        }
        .input2 {
            color: black;
            background-color: RGB(239,239,239);
            font-size: 20px;
            height: 40px;
            width: 100px;
            margin-left:150px;
            margin-right:150px;
            
        }
        .input2:hover{
            background-color:#808080;
        }
        .text{
        	border: none;
            height: 50px;
            width: 100%;
            font-size:16px;
          	
        }

        select {
            border: 0px;
            height: 90%;
            width: 90%;
            outline:none;
        }

        textarea {
            border: 0px;
            
            width: 100%;
            resize: none;
            font-size: 16px;
        }

        .button1 {
            height: 40px;
            width: 120px;
            font-size: 15px;
            margin-left: 1000px;
            position:center;
            color: #000000;
            background-color: #808080;
        }

        h2 {
            text-align: center;
        }
        .button_file{
			background-color: white;
    		color:RGB(64,158,255);    		
    		height:22px;
   	 		text-align: center;
    		font-size: 16px;
    		border:none;
    		font-weight:bold;
		}
		.button_file:hover {
    		background-color:RGB(249,249,249);
		}
		.button_file:active {
 			 transform: translateY(2px);
		}
    </style>
</head>

<body>
<%	
	String ID=(String)session.getAttribute("ID");
	String RequestID=request.getParameter("RequestID");
	String Adminname=null;
	String Status=null;
	//第一个java代码段查询数据
	try{
		Class.forName("org.h2.Driver");//加载驱动
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
		return;
	}
	String url="jdbc:h2:d:/CompanyCar/temp/mydbtest";
	Connection conn=null;

//数据库连接与查询过程中可能会引发sql异常
try {
	//获取数据库连接(url,username,password)			
	conn = DriverManager.getConnection(url,"sa","");
	//准备执行数据库查询	
	
	String sql1="select * from CarRequest where RequestID='"+RequestID+"'";
	String sql2="select Adminname from Admin where ID='"+ID+"'";
	
	//准备SQL执行;
	Statement stmt=conn.createStatement();
	//执行数据库查询，获取结果集
	ResultSet rs1=stmt.executeQuery(sql2);
	if (rs1.next()){
		Adminname=rs1.getString("Adminname");
	}
	ResultSet rs=stmt.executeQuery(sql1);
	if (rs.next()){
			//获取第1个字段
	}
	Status=rs.getString("Status");
%>
    <div class="main">
        <div id="header2">
            <img src="img/申请用车.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
            乘客用车管理 > 申请用车
        </div>
        <h2>用车申请表</h2>
        <form action="C-jdbc-addCheckList.jsp" method="post">
        <table class="had">
            
                <tr>
                    <th>乘车人数：</th>
                    <td><input class="input1" type="number" id="UsersNum" name="UsersNum" min="1" max="6" value=<%=rs.getString("UsersNum") %> readonly></td>
                    <th>用车范围：</th>
                    <td>
                        <input type="text" class="input1" value=<%=rs.getString("UseRange") %> readonly>
                    </td>
                    <th>联系电话：</th>
                    <td><input class="input1" type="text" id="Userphone" name="Userphone" value=<%=rs.getString("Userphone") %> readonly></td>
                </tr>
                <tr>
                    <th>用车时间：</th>
                    <td><input class="input1" type="datetime-local"  id="UseTime" name="UseTime" value=<%=rs.getString("UseTime") %> readonly></td>
                    <th>返回时间：</th>
                    <td><input class="input1" type="datetime-local"  id="ReturnTime" name="ReturnTime" value=<%=rs.getString("ReturnTime") %> readonly></td>
                    <th>紧急程度：</th>
                    <td>
                        <input type="text" class="input1" value=<%=rs.getString("degree") %> readonly>
                    </td>
                </tr>
                <tr>
                    <th>申请人工号：</th>
                    <td><input class="input1" type="text" id="EmpID" name="EmpID" value=<%=rs.getString("EmpID") %> readonly></td>
                    <th>申请时间：</th>
                    <td><input class="input1" type="text"  id="applyTime" name="applyTime" value=<%=rs.getString("applyTime") %> readonly></td>
                    <th>申请部门：</th>
                    <td>
                       
                        <input type="text" class="input1" value=<%=rs.getString("applyDepartment") %> readonly>
                    </td>
                </tr>
            
            
                <tr>
                    <th>起始地点</th>
                    <td colspan="2"><input class="input1" type="text" id="origin" name="origin" value=<%=rs.getString("origin") %> readonly></td>
                    <th>前往地点</th>
                    <td colspan="2"><input class="input1" type="text" id="goPlace" name="goPlace"value=<%=rs.getString("goPlace") %> readonly></td>
                </tr>
                <tr>
                    <th style="height:100px">用车事由</th>
                    <td colspan="5"><textarea id="UseReasons" name="UseReasons" rows="8" cols="30" style="outline:none;"readonly><%=rs.getString("UseReasons") %> </textarea></td>
                </tr>
            
            
                <tr >
                    <th >备注</th>
                    <td colspan="5" ><textarea id="Remarks" name="Remarks" rows="3" cols="30" style="outline:none;"readonly><%=rs.getString("Remarks") %> </textarea></td>
                </tr>
           		<tr>
                    <th style="height:50px">附件</th>
                    <td colspan="5" style="text-align:left">	
                    	<input type="button" class="button_file" value="添加附件" onclick="path.click()" >					
						<input type="text" class="text" name="lookfile" id="lookfile" style="outline:none;" value=<%=rs.getString("Attachment") %> readonly>											
						<input type="file"  id="Attachment" name="Attachment" style="display:none" onchange="lookfile.value+='   '+this.value">								
					</td>
                </tr> 
                <tr>
                	<th style="height:100px" rowspan="3">审核意见</th>
                	<td colspan="5" style="padding:0px;text-align:left;">
                    	<select id="AgreeOrNot" name="AgreeOrNot" style="height:28px;width:30%;">
                        	<option value="" selected disabled hidden>请选择是否同意</option>
                            <option value="同意">同意</option>
                            <option value="不同意，退回修改">不同意，退回修改</option>
                            <option value="不同意，结束任务">不同意，结束任务</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" ><textarea rows="3" cols="30" style="outline:none;" id="CensorContent" name="CensorContent"required></textarea></td>                 
                </tr>
                <tr>
                	<td colspan="5" style="text-align:right;">
                		<div style="float:right;width:100%">
                			审核人：<input type="text" id="Adminname" name="Adminname" style="border:none;outline:none;width:150px;height:20px;white-space: nowrap;color:RGB(153,153,153);" value=<%=Adminname%> readonly>
                			审核时间：<input type="text" id="AdminTime" name="AdminTime" style="border:none;outline:none;width:150px;height:20px;color:RGB(153,153,153);"readonly>
                		</div>
                	</td>
                </tr>
        </table>
        <br/>
        <input type="hidden" name="RequestID" value=<%=RequestID %>>
        <input type="button" onclick="Return()" class="input2" value="返回" style="white-space: nowrap;">
        <input type="submit" onclick="test()" class="input2" value="提交" style="white-space: nowrap;">
        <input type="reset" class="input2" value="清空">
        </form>
    </div>
<%
	//关闭表达式对象
	stmt.close();			
	//关闭数据库			
	conn.close();			
	
} catch (SQLException e) {
	e.printStackTrace();
} finally{
	//防止数据库未正常关闭
	try{
		if (conn!=null && (!conn.isClosed())){
			conn.close();
		}
	}catch(SQLException e){
		e.printStackTrace();
	}
}
%>    
 <script type="text/javascript">
 function gettime() {
     var time = new Date();
     var hour = time.getHours();
     var min = time.getMinutes();
     var sec = time.getSeconds();
     var madetime = time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate() ;
     document.getElementById("AdminTime").value = madetime;
 }
 gettime();//显示第一秒的时间
 setInterval("gettime()", 1000);
 function Return()
 {	
	 var S="<%=Status%>";
	 
	 if(S=="待审核")
	 	window.location.href="C-Use_Check.jsp";
	 else if(S=="审核通过")
		 window.location.href="C-success.jsp";
	 else
		 window.location.href="C-fail.jsp";
 }
 </script>
   

</body>

</html>
